fix: address PR review comments#1912
Conversation
Signed-off-by: Ayush <ayumane63@gmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for configurable Kubernetes cluster DNS domains and updates default Grafana MCP URLs to use fully-qualified in-cluster service DNS, improving internal URL detection and security.
Changes:
- Update Helm default Grafana API URL to
http://grafana.<ns>.svc.cluster.local:3000/api. - Introduce
--cluster-domainconfig/flag and plumb it through the HTTP server/handlers into the agent translator. - Harden internal Kubernetes URL detection logic and add unit tests for cluster-domain handling.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| helm/tools/grafana-mcp/values.yaml | Updates default Grafana API URL to in-cluster FQDN with scheme. |
| helm/kagent/values.yaml | Aligns kagent chart’s grafana-mcp URL default with in-cluster FQDN. |
| go/core/pkg/app/app.go | Adds ClusterDomain config/flag and passes it into the translator. |
| go/core/internal/httpserver/server.go | Extends server config and handler construction to include ClusterDomain. |
| go/core/internal/httpserver/handlers/handlers.go | Stores ClusterDomain in handler base and extends NewHandlers signature. |
| go/core/internal/httpserver/handlers/agents.go | Passes ClusterDomain to the agent translator. |
| go/core/internal/controller/translator/agent/cluster_domain_test.go | Adds tests covering internal URL detection across cluster domains. |
| go/core/internal/controller/translator/agent/adk_api_translator.go | Adds ClusterDomain support, improves internal URL validation, and refactors namespace checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (a *adkApiTranslator) namespaceExistsOrWatched(ctx context.Context, potentialNamespace string) bool { | ||
| ns := &corev1.Namespace{} | ||
| err := a.kube.Get(ctx, types.NamespacedName{Name: potentialNamespace}, ns) | ||
| if err == nil { | ||
| return true | ||
| } | ||
| if (apierrors.IsForbidden(err) || apierrors.IsUnauthorized(err)) && len(a.watchedNamespaces) > 0 { | ||
| return slices.Contains(a.watchedNamespaces, potentialNamespace) | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| return false | ||
| } |
| if validation.IsDNS1123Label(parts[0]) != nil || validation.IsDNS1123Label(parts[1]) != nil { | ||
| return false | ||
| } |
| scheme := k8sscheme.Scheme | ||
| require.NoError(t, v1alpha2.AddToScheme(scheme)) |
- Remove stray return/brace in adk_api_translator.go - Use len(validation.IsDNS1123Label(...)) > 0 checks - Use fresh scheme in cluster_domain_test.go Signed-off-by: Automated Fix <auto-fix@example.com> Signed-off-by: Ayush <ayumane63@gmail.com>
| clusterDomain = "cluster.local" | ||
| } | ||
| a.clusterDomain = clusterDomain | ||
| return a |
There was a problem hiding this comment.
nit: prefer using a != nil instead for slightly better readability
| return a | |
| if a != nil { | |
| clusterDomain = strings.TrimSpace(clusterDomain) | |
| if clusterDomain == "" { | |
| clusterDomain = "cluster.local" | |
| } | |
| a.clusterDomain = clusterDomain | |
| } | |
| return a |
| // Extract namespace from hostname pattern: {name}.{namespace} | ||
| // Examples: test-mcp-server.kagent -> namespace is "kagent" |
There was a problem hiding this comment.
nit: can we keep this comment? this seems to still be relevant so it would be good context.
| return a.namespaceExistsOrWatched(ctx, potentialNamespace) | ||
| } | ||
|
|
||
| if len(parts) == 3 && parts[2] == "svc" { |
There was a problem hiding this comment.
nit: would be helpful to add a comment that this conditional specifically addressesing a hostname using the grafana.kagent.svc construction
Addressed the review feedback by wiring
clusterDomaininto the actual runtime flow instead of leaving it unused, tightening internal.svcURL detection to avoid matching external domains incorrectly, fixing the related comments/documentation, restoring the Grafana MCP default service URL, and adding regression tests for cluster-domain-aware URL handling. Also propagated the config through the HTTP server and translator paths so custom cluster domains are consistently supported end-to-end